﻿/*
* CRM_Customer.cs
*
* 功 能： N/A
* 类 名： CRM_Customer
*
* Ver    变更日期             负责人     变更内容
* ───────────────────────────────────
* V1.0  2015-06-22 11:32:23    黄润伟    
*
* Copyright (c) 2015 www.xhdcrm.com   All rights reserved.
*┌──────────────────────────────────┐
*│　版权所有：黄润伟                      　　　　　　　　　　　　　　│
*└──────────────────────────────────┘
*/

using System;
using System.Data;
using XHD.Common;

namespace XHD.BLL
{
    /// <summary>
    ///     CRM_Customer
    /// </summary>
    public class CRM_Customer
    {
        private readonly DAL.CRM_Customer dal = new DAL.CRM_Customer();

        #region  BasicMethod		

        /// <summary>
        ///     增加一条数据
        /// </summary>
        public int Add(Model.CRM_Customer model)
        {
            return dal.Add(model);
        }

        /// <summary>
        ///     更新一条数据
        /// </summary>
        public bool Update(Model.CRM_Customer model)
        {
            return dal.Update(model);
        }

        /// <summary>
        ///     删除一条数据
        /// </summary>
        public bool Delete(int id)
        {
            return dal.Delete(id);
        }

        /// <summary>
        ///     删除一条数据
        /// </summary>
        public bool DeleteList(string idlist)
        {
            return dal.DeleteList(PageValidate.SafeLongFilter(idlist, 0));
        }

        /// <summary>
        ///     获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }

        /// <summary>
        ///     获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        public DataSet ToExcel(int Top, string strWhere, string filedOrder)
        {
            return dal.ToExcel(Top, strWhere, filedOrder);
        }
        /// <summary>
        ///     获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        ///     分页获取数据列表
        ///     分页获取数据列表
        /// </summary>
        public DataSet GetList(int PageSize, int PageIndex, string strWhere, string filedOrder, out string Total)
        {
            return dal.GetList(PageSize, PageIndex, strWhere, filedOrder, out Total);
        }
        public DataSet GetMapList(string strWhere)
        {
            return dal.GetMapList(strWhere);
        }

        #endregion  BasicMethod

        #region  ExtensionMethod

        /// <summary>
        ///     批量转客源
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Update_batch(Model.CRM_Customer model, string strWhere)
        {
            return dal.Update_batch(model, strWhere);
        }

        /// <summary>
        ///     预删除
        /// </summary>
        /// <param name="id"></param>
        /// <param name="isDelete"></param>
        /// <param name="time"></param>
        /// <returns></returns>
        public bool AdvanceDelete(int id, int isDelete, string time)
        {
            return dal.AdvanceDelete(id, isDelete, time);
        }

        /// <summary>
        ///     更新最后跟进
        /// </summary>
        public bool UpdateLastFollow(string id)
        {
            return dal.UpdateLastFollow(id);
        }

        public DataSet Reports_year(string items, int year, string where)
        {
            return dal.Reports_year(items, year, where);
        }

        /// <summary>
        ///     同比环比【客户新增】
        /// </summary>
        /// <param name="dt1"></param>
        /// <param name="dt2"></param>
        /// <param name="project_id"></param>
        /// <returns></returns>
        public DataSet Compared(string year1, string month1, string year2, string month2)
        {
            return dal.Compared(year1, month1, year2, month2);
        }

        public DataSet Compared_type(string year1, string month1, string year2, string month2)
        {
            return dal.Compared_type(year1, month1, year2, month2);
        }

        public DataSet Compared_level(string year1, string month1, string year2, string month2)
        {
            return dal.Compared_level(year1, month1, year2, month2);
        }

        public DataSet Compared_source(string year1, string month1, string year2, string month2)
        {
            return dal.Compared_source(year1, month1, year2, month2);
        }

        public DataSet Compared_empcusadd(string year1, string month1, string year2, string month2, string idlist)
            //, string idlist)
        {
            return dal.Compared_empcusadd(year1, month1, year2, month2, idlist); //, idlist);
        }

        /// <summary>
        ///     客户新增统计
        /// </summary>
        /// <param name="year"></param>
        /// <param name="idlist"></param>
        /// <returns></returns>
        public DataSet report_empcus(int year, string idlist)
        {
            return dal.report_empcus(year, idlist);
        }

        /// <summary>
        ///     统计漏斗
        /// </summary>
        public DataSet Funnel(string strWhere, string year)
        {
            return dal.Funnel(strWhere, year);
        }

        #endregion  ExtensionMethod
    }
}